package com.smart.service;

import java.sql.SQLException;

import com.smart.dao.RanCodeDAO;
import com.smart.model.RanCode;

public class RanCodeService {
	private static RanCodeDAO rancodeDAO;
	static
	{
		rancodeDAO=new RanCodeDAO();
	}
	public boolean isUserIdExist(int userId)
	{
		boolean flag=false;
		try {
			flag=rancodeDAO.isUserIdExist(userId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	  }
	  public int insert(int userId,String identifier)
	  {
		  int x=0;
		  try {
			x=rancodeDAO.insert(userId, identifier);
		  } catch (SQLException e) {
			e.printStackTrace();
		  }
		  return x;
	  }
	  
	  public RanCode getRanCode(int userId)
	  {
		  RanCode ranCode=null;
		  try {
			  ranCode=rancodeDAO.getRanCode(userId);
		  } catch (SQLException e) {
			e.printStackTrace();
		  }
		  return ranCode;
	  }
	  
	  public int updateIdentifier(String identifier,int userId)
	  {
		  int x=0;
		  try {
			x=rancodeDAO.updateIdentifier(identifier, userId);
		  } catch (SQLException e) {
			e.printStackTrace();
		  }
		  return x;
	  }
	  public static void main(String[] args)
	  {
		  int userId=36;
		  System.out.println(new RanCodeService().getRanCode(userId));
	  }
}
